package com.ymatou.iapi.auth.testcase;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.JsonObject;
import com.ymatou.iapi.auth.parameter.SignAuthRequestDtoBean;
import com.ymatou.iapi.auth.parameter.UserTokenDtoBean;
import com.ymatou.iapi.auth.service.SignAuthRequestDtoCall;
import com.ymatou.iapi.auth.service.UserTokenDtoCall;
import com.ymatou.iapi.userregister.parameter.UserRegisterInfoRequestDtoBean;
import com.ymatou.iapi.userregister.service.UserRegisterInfoRequestDtoCall;
import com.ymatou.iapi.userservice.parameter.req.CreateUserReq;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.JUserCallService;
import com.ymttest.database.mongo.UserTokenWapper;
import com.ymttest.utils.YMTDateUtil;
/**
*验证token
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_SignAuthRequestDto{
	private static SignAuthRequestDtoBean signauthrequestdtoBean;
	private static SignAuthRequestDtoCall signauthrequestdtoCall;
	private static UserTokenDtoBean userTokenDtoBean = new UserTokenDtoBean();
	private static UserTokenDtoCall userTokenDtoCall = new UserTokenDtoCall();
	private UserTokenWapper userTokenWapper;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("验证token");
	}

	@Before
	public void caseUp() throws Exception {
		signauthrequestdtoBean=new SignAuthRequestDtoBean();
		signauthrequestdtoCall=new SignAuthRequestDtoCall();
		userTokenWapper=new UserTokenWapper();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(signauthrequestdtoCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	
	/**
	 * 创建token时，使用UserTokenDto接口，设置过期时间，验证token时，使用SignAuthRequestDto接口，过期时间采用默认策略
	 */
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_SignAuthRequestDto_001() {
		Logger.start(true,"有效的token,返回成功");
		try {
			UserRegisterInfoRequestDtoBean cur = new UserRegisterInfoRequestDtoBean();
			cur = JUserCallService.initUserRegisterInfoRequestDtoBean();
			cur.setClientIp("218.22.32.186 ");
			cur.setDeviceId("123456");
			UserRegisterInfoRequestDtoCall urrc =JUserCallService.UserRegisterInfoRequestDtoCall(cur); 
			JsonObject registerResult = urrc.getJsonObject().get("Result").getAsJsonObject();
			String AccessToken=registerResult.get("Token").getAsString();
			
			signauthrequestdtoBean.setToken(AccessToken);
			signauthrequestdtoBean.setSClientType("testtype");
			signauthrequestdtoBean.setDeviceId("123457");
			signauthrequestdtoBean.setTokenSource("App");
			signauthrequestdtoBean.setClientIp("172.17.21.254");
			
			signauthrequestdtoCall.setData(signauthrequestdtoBean);
			signauthrequestdtoCall.callService();	
			
			Logger.verifyEquals(true, signauthrequestdtoCall.getSuccess(), "验证Success");
			Logger.verifyEquals(200, signauthrequestdtoCall.getCode(), "验证Code");
			

			Map<String, Object> userlst= userTokenWapper.getUserUidByToken(AccessToken);
			if(userlst!=null && userlst.size()> 0)
			{
			  Logger.verifyEquals(userlst.get("uId"), signauthrequestdtoCall.getUserId(), "验证uid");
			}
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_SignAuthRequestDto_002() {
		Logger.start(true,"无效的token,返回失败");
		try {
			signauthrequestdtoBean.setToken("123321");
			signauthrequestdtoBean.setSClientType("testtype");
			signauthrequestdtoBean.setDeviceId("aa");
			signauthrequestdtoBean.setTokenSource("App");
			signauthrequestdtoBean.setClientIp("0.0.0.0");
			
			signauthrequestdtoCall.setData(signauthrequestdtoBean);
			signauthrequestdtoCall.callService();	
			
			Logger.verifyEquals(false, signauthrequestdtoCall.getSuccess(), "验证Success");
			Logger.verifyEquals(-160, signauthrequestdtoCall.getCode(), "验证Code");
			
			Logger.verifyEquals("未找到token", signauthrequestdtoCall.getLastErrorMessage(), "验证LastErrorMessage");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_SignAuthRequestDto_003() {
		Logger.start(true,"有效的token,tokeSource为空");
		try {
			 CreateUserReq cur = new CreateUserReq();
			 cur = JUserCallService.initCreateUserBean(cur);
			 int uid = JUserCallService.createUserCall(cur);
			 userTokenDtoBean.setUserId(uid);
			 userTokenDtoBean.setTokenSource("App");
			 userTokenDtoBean.setDeviceId("shuagshuang");
			 userTokenDtoBean.setContext("reg");
			 userTokenDtoBean.setClientIp("134.565.23.56");
			 userTokenDtoCall.setData(userTokenDtoBean);
			 userTokenDtoCall.callService();
			 String token = userTokenDtoCall.getResult();
			 
			 signauthrequestdtoBean.setToken(token);
			 signauthrequestdtoBean.setDeviceId(userTokenDtoBean.getDeviceId());
		 	 signauthrequestdtoBean.setClientIp(userTokenDtoBean.getClientIp());
			
			 signauthrequestdtoCall.setData(signauthrequestdtoBean);
			 signauthrequestdtoCall.callService();	
			
			 Logger.verifyEquals(true, signauthrequestdtoCall.getSuccess(), "验证Success");
			 Logger.verifyEquals(200, signauthrequestdtoCall.getCode(), "验证Code");
			 Logger.verifyEquals(userTokenDtoBean.getUserId(), signauthrequestdtoCall.getUserId(), "验证userid");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_SignAuthRequestDto_004() {
		Logger.start(true,"有效的token,tokeSource为WxApp");
		try {
			 CreateUserReq cur = new CreateUserReq();
			 cur = JUserCallService.initCreateUserBean(cur);
			 int uid = JUserCallService.createUserCall(cur);
			 Thread.sleep(100);
			 userTokenDtoBean.setUserId(uid);
			 userTokenDtoBean.setTokenSource("WxApp");
			 userTokenDtoBean.setDeviceId("shuagshuang");
			 userTokenDtoBean.setContext("reg");
			 userTokenDtoBean.setClientIp("134.565.23.56");
			 userTokenDtoCall.setData(userTokenDtoBean);
			 userTokenDtoCall.callService();
			 String token = userTokenDtoCall.getResult();
			 
			 signauthrequestdtoBean.setToken(token);
			 signauthrequestdtoBean.setDeviceId(userTokenDtoBean.getDeviceId());
		 	 signauthrequestdtoBean.setClientIp(userTokenDtoBean.getClientIp());
		 	 signauthrequestdtoBean.setTokenSource("WxApp");
		 	signauthrequestdtoBean.setClientIp("134.565.23.56");
			
			 signauthrequestdtoCall.setData(signauthrequestdtoBean);
			 signauthrequestdtoCall.callService();	
			
			 Logger.verifyEquals(true, signauthrequestdtoCall.getSuccess(), "验证Success");
			 Logger.verifyEquals(200, signauthrequestdtoCall.getCode(), "验证Code");
			 Logger.verifyEquals(userTokenDtoBean.getUserId(), signauthrequestdtoCall.getUserId(), "验证userid");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_SignAuthRequestDto_005() {
		Logger.start(true,"无效的token,tokeSource为WxApp");
		try {
			 CreateUserReq cur = new CreateUserReq();
			 cur = JUserCallService.initCreateUserBean(cur);
			 int uid = JUserCallService.createUserCall(cur);
			 userTokenDtoBean.setUserId(uid);
			 userTokenDtoBean.setTokenSource("WxApp");
			 userTokenDtoBean.setDeviceId("shuagshuang");
			 userTokenDtoBean.setContext("reg");
			 userTokenDtoBean.setClientIp("134.565.23.56");
			 userTokenDtoCall.setData(userTokenDtoBean);
			 userTokenDtoCall.callService();
			 String token = userTokenDtoCall.getResult();
			 
			 signauthrequestdtoBean.setToken("hqhwruhq");
			 signauthrequestdtoBean.setDeviceId(userTokenDtoBean.getDeviceId());
		 	 signauthrequestdtoBean.setClientIp(userTokenDtoBean.getClientIp());
		 	 signauthrequestdtoBean.setTokenSource("WxApp");
		 	signauthrequestdtoBean.setClientIp("134.565.23.56");
			
			 signauthrequestdtoCall.setData(signauthrequestdtoBean);
			 signauthrequestdtoCall.callService();	
			
			 Logger.verifyEquals(false, signauthrequestdtoCall.getSuccess(), "验证Success");
			 Logger.verifyEquals(-160, signauthrequestdtoCall.getCode(), "验证Code");
			// Logger.verifyEquals(userTokenDtoBean.getUserId(), signauthrequestdtoCall.getUserId(), "验证userid");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	/**
	 * 这地方用了缓存
	 */
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_SignAuthRequestDto_006() {
		Logger.start(true,"有效的token,1分钟内多次验证");
		try {
			 CreateUserReq cur = new CreateUserReq();
			 cur = JUserCallService.initCreateUserBean(cur);
			 int uid = JUserCallService.createUserCall(cur);
			 userTokenDtoBean.setUserId(uid);
			 userTokenDtoBean.setTokenSource("WxApp");
			 userTokenDtoBean.setDeviceId("shuagshuang");
			 userTokenDtoBean.setContext("reg");
			 userTokenDtoBean.setClientIp("134.565.23.56");
			 userTokenDtoCall.setData(userTokenDtoBean);
			 userTokenDtoCall.callService();
			 String token = userTokenDtoCall.getResult();
			 
			 for(int i =0;i<5;i++){
				 signauthrequestdtoBean.setToken(token);
				 signauthrequestdtoBean.setDeviceId(userTokenDtoBean.getDeviceId());
			 	 signauthrequestdtoBean.setClientIp(userTokenDtoBean.getClientIp());
			 	 signauthrequestdtoBean.setTokenSource("WxApp");
				
				 signauthrequestdtoCall.setData(signauthrequestdtoBean);
				 signauthrequestdtoCall.callService();
				 Logger.verifyEquals(true, signauthrequestdtoCall.getSuccess(), "验证Success");
				 Logger.verifyEquals(200, signauthrequestdtoCall.getCode(), "验证Code");
				 Logger.verifyEquals(userTokenDtoBean.getUserId(), signauthrequestdtoCall.getUserId(), "验证userid");
			 }
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_SignAuthRequestDto_007() {
		Logger.start(true,"有效的token,token过期");
		try {
			 CreateUserReq cur = new CreateUserReq();
			 cur = JUserCallService.initCreateUserBean(cur);
			 int uid = JUserCallService.createUserCall(cur);
			 Thread.sleep(100);
			 userTokenDtoBean.setUserId(uid);
			 userTokenDtoBean.setTokenSource("WxApp");
			 userTokenDtoBean.setDeviceId("shuagshuang");
			 userTokenDtoBean.setContext("reg");
			 userTokenDtoBean.setClientIp("134.565.23.56");
			 userTokenDtoBean.setTokenTimeOut(1L);
			 userTokenDtoCall.setData(userTokenDtoBean);
			 userTokenDtoCall.callService();
			 
			 String BeginTime = YMTDateUtil.getBeforeOrNextDay(-2, YMTDateUtil.YMDHMSS);
			 String EndTime = YMTDateUtil.getBeforeOrNextDay(-1, YMTDateUtil.YMDHMSS);
			 Logger.debug(BeginTime);
			 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
			 Date beginTime = sdf.parse(BeginTime);
			 Date endTime = sdf.parse(EndTime);
			 
			 new UserTokenWapper().updateStartTimeByUserId(uid, beginTime);
			 new UserTokenWapper().updateEndTimeByUserId(uid, endTime);
			 
			 String token = userTokenDtoCall.getResult();
			 signauthrequestdtoBean.setToken(token);
			 signauthrequestdtoBean.setDeviceId(userTokenDtoBean.getDeviceId());
		 	 signauthrequestdtoBean.setClientIp(userTokenDtoBean.getClientIp());
		 	 signauthrequestdtoBean.setTokenSource("WxApp");
			
			 signauthrequestdtoCall.setData(signauthrequestdtoBean);
			 signauthrequestdtoCall.callService();
			 Thread.sleep(20);
			 Logger.verifyEquals(false, signauthrequestdtoCall.getSuccess(), "验证Success");
			 Logger.verifyEquals(-220, signauthrequestdtoCall.getCode(), "验证Code");
			 Logger.verifyEquals(userTokenDtoBean.getUserId(), signauthrequestdtoCall.getUserId(), "验证userid");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_SignAuthRequestDto_008() {
		Logger.start(true,"有效的token,tokeSource为WxApp，ip地址不一致");
		try {
			 CreateUserReq cur = new CreateUserReq();
			 cur = JUserCallService.initCreateUserBean(cur);
			 int uid = JUserCallService.createUserCall(cur);
			 Thread.sleep(100);
			 userTokenDtoBean.setUserId(uid);
			 userTokenDtoBean.setTokenSource("WxApp");
			 userTokenDtoBean.setDeviceId("shuagshuang");
			 userTokenDtoBean.setContext("reg");
			 userTokenDtoBean.setClientIp("125.565.23.56");
			 userTokenDtoCall.setData(userTokenDtoBean);
			 userTokenDtoCall.callService();
			 String token = userTokenDtoCall.getResult();
			 
			 signauthrequestdtoBean.setToken(token);
			 signauthrequestdtoBean.setDeviceId(userTokenDtoBean.getDeviceId());
		 	 signauthrequestdtoBean.setClientIp(userTokenDtoBean.getClientIp());
		 	 signauthrequestdtoBean.setTokenSource("WxApp");
		 	signauthrequestdtoBean.setClientIp("134.565.23.56");
			
			 signauthrequestdtoCall.setData(signauthrequestdtoBean);
			 signauthrequestdtoCall.callService();	
			
			 Logger.verifyEquals(true, signauthrequestdtoCall.getSuccess(), "验证Success");
			 Logger.verifyEquals(200, signauthrequestdtoCall.getCode(), "验证Code");
			 Logger.verifyEquals(userTokenDtoBean.getUserId(), signauthrequestdtoCall.getUserId(), "验证userid");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_SignAuthRequestDto_009() {
		Logger.start(true,"有效的token,tokeSource为UnKnow，ip地址一致,验证level字段");
		try {
			 CreateUserReq cur = new CreateUserReq();
			 cur = JUserCallService.initCreateUserBean(cur);
			 int uid = JUserCallService.createUserCall(cur);
			 userTokenDtoBean.setUserId(uid);
			 userTokenDtoBean.setTokenSource("UnKnown");
			 userTokenDtoBean.setDeviceId("shuagshuang");
			 userTokenDtoBean.setContext("reg");
			 userTokenDtoBean.setClientIp("125.565.23.56");
			 userTokenDtoCall.setData(userTokenDtoBean);
			 userTokenDtoCall.callService();
			 String token = userTokenDtoCall.getResult();
			 
			 signauthrequestdtoBean.setToken(token);
			 signauthrequestdtoBean.setDeviceId(userTokenDtoBean.getDeviceId());
		 	 signauthrequestdtoBean.setClientIp(userTokenDtoBean.getClientIp());
		 	 signauthrequestdtoBean.setTokenSource("UnKnown");
		 	 signauthrequestdtoBean.setClientIp("125.565.23.56");
		 	 signauthrequestdtoBean.setDescription("验证token");
		 	 signauthrequestdtoBean.setsClientType("ios");
		 	 signauthrequestdtoBean.setTSource("Pc");
			
			 signauthrequestdtoCall.setData(signauthrequestdtoBean);
			 signauthrequestdtoCall.callService();	
			
			 Logger.verifyEquals(true, signauthrequestdtoCall.getSuccess(), "验证Success");
			 Logger.verifyEquals(200, signauthrequestdtoCall.getCode(), "验证Code");
			 Logger.verifyEquals(userTokenDtoBean.getUserId(), signauthrequestdtoCall.getUserId(), "验证userid");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_SignAuthRequestDto_010() {
		Logger.start(true,"有效的token,tokeSource为SellerApp");
		try {
			 CreateUserReq cur = new CreateUserReq();
			 cur = JUserCallService.initCreateUserBean(cur);
			 int uid = JUserCallService.createUserCall(cur);
			 userTokenDtoBean.setUserId(uid);
			 userTokenDtoBean.setTokenSource("SellerApp");
			 userTokenDtoBean.setDeviceId("shuagshuang");
			 userTokenDtoBean.setContext("reg");
			 userTokenDtoBean.setClientIp("125.565.23.56");
			 userTokenDtoCall.setData(userTokenDtoBean);
			 userTokenDtoCall.callService();
			 String token = userTokenDtoCall.getResult();
			 
			 signauthrequestdtoBean.setToken(token);
			 signauthrequestdtoBean.setTokenSource("SellerApp");
			 signauthrequestdtoBean.setDeviceId("gsqdui");
		 	 signauthrequestdtoBean.setClientIp("125.56.23.56");
			
			 signauthrequestdtoCall.setData(signauthrequestdtoBean);
			 signauthrequestdtoCall.callService();	
			
			 Logger.verifyEquals(true, signauthrequestdtoCall.getSuccess(), "验证Success");
			 Logger.verifyEquals(200, signauthrequestdtoCall.getCode(), "验证Code");
			 Logger.verifyEquals(userTokenDtoBean.getUserId(), signauthrequestdtoCall.getUserId(), "验证userid");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_SignAuthRequestDto_011() {
		Logger.start(true,"有效的token,tokeSource为SellerPc");
		try {
			 CreateUserReq cur = new CreateUserReq();
			 cur = JUserCallService.initCreateUserBean(cur);
			 int uid = JUserCallService.createUserCall(cur);
			 userTokenDtoBean.setUserId(uid);
			 userTokenDtoBean.setTokenSource("SellerPc");
			 userTokenDtoBean.setDeviceId("shuagshuang");
			 userTokenDtoBean.setContext("reg");
			 userTokenDtoBean.setClientIp("125.565.23.56");
			 userTokenDtoCall.setData(userTokenDtoBean);
			 userTokenDtoCall.callService();
			 String token = userTokenDtoCall.getResult();
			 
			 signauthrequestdtoBean.setToken(token);
			 signauthrequestdtoBean.setTokenSource("SellerPc");
			 signauthrequestdtoBean.setDeviceId("gsqdui");
		 	 signauthrequestdtoBean.setClientIp("125.56.23.56");
			
			 signauthrequestdtoCall.setData(signauthrequestdtoBean);
			 signauthrequestdtoCall.callService();	
			
			 Logger.verifyEquals(true, signauthrequestdtoCall.getSuccess(), "验证Success");
			 Logger.verifyEquals(200, signauthrequestdtoCall.getCode(), "验证Code");
			 Logger.verifyEquals(userTokenDtoBean.getUserId(), signauthrequestdtoCall.getUserId(), "验证userid");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_SignAuthRequestDto_012() {
		Logger.start(true,"有效的token,tokeSource为SellerPc,创建时无deviceId和ip");
		try {
			 CreateUserReq cur = new CreateUserReq();
			 cur = JUserCallService.initCreateUserBean(cur);
			 int uid = JUserCallService.createUserCall(cur);
			 Thread.sleep(100);
			 userTokenDtoBean.setUserId(uid);
			 userTokenDtoBean.setTokenSource("SellerPc");
			 userTokenDtoBean.setContext("reg");
			 userTokenDtoCall.setData(userTokenDtoBean);
			 userTokenDtoCall.callService();
			 String token = userTokenDtoCall.getResult();
			 
			 signauthrequestdtoBean.setToken(token);
			 signauthrequestdtoBean.setTokenSource("SellerPc");
			 signauthrequestdtoBean.setDeviceId("gsqdui");
		 	 signauthrequestdtoBean.setClientIp("125.565.23.56");
			
			 signauthrequestdtoCall.setData(signauthrequestdtoBean);
			 signauthrequestdtoCall.callService();	
			 
			 signauthrequestdtoBean.setTokenSource("SellerPc");
			 signauthrequestdtoBean.setDeviceId("dshjsfj");
		 	 signauthrequestdtoBean.setClientIp("124.55.23.56");
		 	 signauthrequestdtoCall.callService();	
		 	 
			 Logger.verifyEquals(true, signauthrequestdtoCall.getSuccess(), "验证Success");
			 Logger.verifyEquals(200, signauthrequestdtoCall.getCode(), "验证Code");
			 Logger.verifyEquals(userTokenDtoBean.getUserId(), signauthrequestdtoCall.getUserId(), "验证userid");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_SignAuthRequestDto_013() {
		Logger.start(true,"有效的token,tokeSource为SellerPc,创建时无deviceId和ip");
		try {
			 CreateUserReq cur = new CreateUserReq();
			 cur = JUserCallService.initCreateUserBean(cur);
			 int uid = JUserCallService.createUserCall(cur);
			 userTokenDtoBean.setUserId(uid);
			 userTokenDtoBean.setTokenSource("SellerPc");
			 userTokenDtoBean.setContext("reg");
			 userTokenDtoCall.setData(userTokenDtoBean);
			 userTokenDtoCall.callService();
			 String token = userTokenDtoCall.getResult();
			 
			 signauthrequestdtoBean.setToken(token);
			 signauthrequestdtoBean.setTokenSource("SellerPc");
			 signauthrequestdtoBean.setDeviceId("gsqdui");
			
			 signauthrequestdtoCall.setData(signauthrequestdtoBean);
			 signauthrequestdtoCall.callService();	
			 
			 signauthrequestdtoBean.setTokenSource("SellerPc");
			 signauthrequestdtoBean.setDeviceId("dshjsfj");
		 	 signauthrequestdtoBean.setClientIp("124.55.23.56");
		 	 signauthrequestdtoCall.callService();	
		 	 
			 Logger.verifyEquals(true, signauthrequestdtoCall.getSuccess(), "验证Success");
			 Logger.verifyEquals(200, signauthrequestdtoCall.getCode(), "验证Code");
			 Logger.verifyEquals(userTokenDtoBean.getUserId(), signauthrequestdtoCall.getUserId(), "验证userid");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_SignAuthRequestDto_014() {
		Logger.start(true,"有效的token,tokeSource为SellerPc,创建时无deviceId和ip,缓存");
		try {
			 CreateUserReq cur = new CreateUserReq();
			 cur = JUserCallService.initCreateUserBean(cur);
			 int uid = JUserCallService.createUserCall(cur);
			 
			 userTokenDtoBean.setUserId(uid);
			 userTokenDtoBean.setTokenSource("SellerPc");
			 userTokenDtoBean.setContext("reg");
			 userTokenDtoBean.setDeviceId("	");
			 userTokenDtoBean.setClientIp("132.36.75.32");
			 userTokenDtoCall.setData(userTokenDtoBean);
			 userTokenDtoCall.callService();
			 
			 String token = userTokenDtoCall.getResult();
			 
			 for(int i= 0;i<5;i++){
				 signauthrequestdtoBean.setToken(token);
				 signauthrequestdtoBean.setTokenSource("SellerPc");
				 signauthrequestdtoBean.setDeviceId("yurwg");
				 signauthrequestdtoBean.setClientIp("122.36.75.38");
				 signauthrequestdtoCall.setData(signauthrequestdtoBean);
				 signauthrequestdtoCall.callService();
				 Thread.sleep(3000);
			 }
			 
		 	 
			 Logger.verifyEquals(true, signauthrequestdtoCall.getSuccess(), "验证Success");
			 Logger.verifyEquals(200, signauthrequestdtoCall.getCode(), "验证Code");
			 Logger.verifyEquals(userTokenDtoBean.getUserId(), signauthrequestdtoCall.getUserId(), "验证userid");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_SignAuthRequestDto_015() {
		Logger.start(true,"有效的token,tokeSource为SellerPc,创建时无deviceId和ip,记录日志");
		try {
			 CreateUserReq cur = new CreateUserReq();
			 cur = JUserCallService.initCreateUserBean(cur);
			 int uid = JUserCallService.createUserCall(cur);
			 Thread.sleep(100);
			 userTokenDtoBean.setUserId(uid);
			 userTokenDtoBean.setTokenSource("SellerPc");
			 userTokenDtoBean.setContext("reg");
			 userTokenDtoBean.setDeviceId("	");
			 userTokenDtoBean.setClientIp("132.36.75.32");
			 userTokenDtoCall.setData(userTokenDtoBean);
			 userTokenDtoCall.callService();
			 
			 String token = userTokenDtoCall.getResult();
			 
			 signauthrequestdtoBean.setToken(token);
			 signauthrequestdtoBean.setTokenSource("SellerPc");
			 signauthrequestdtoBean.setDeviceId("yurwg");
			 signauthrequestdtoBean.setClientIp("122.36.75.38");
			 signauthrequestdtoCall.setData(signauthrequestdtoBean);
			 signauthrequestdtoCall.callService();
			 Thread.sleep(3000);
			 
			 
			 signauthrequestdtoBean.setToken(token);
			 signauthrequestdtoBean.setTokenSource("SellerPc");
			 signauthrequestdtoBean.setDeviceId("yurwg");
			 signauthrequestdtoBean.setClientIp("122.36.75.38");
			 signauthrequestdtoCall.setData(signauthrequestdtoBean);
			 signauthrequestdtoCall.callService();	
			 
			 Thread.sleep(3000);
			 signauthrequestdtoBean.setToken(token);
			 signauthrequestdtoBean.setTokenSource("SellerPc");
			 signauthrequestdtoBean.setDeviceId("ewrgg");
			 signauthrequestdtoBean.setClientIp("112.36.75.38");
			 signauthrequestdtoCall.setData(signauthrequestdtoBean);
			 signauthrequestdtoCall.callService();	
			 Thread.sleep(3000);
			
			 signauthrequestdtoBean.setTokenSource("SellerPc");
			 signauthrequestdtoBean.setDeviceId("dshjsfj");
		 	 signauthrequestdtoBean.setClientIp("124.55.23.56");
		 	 signauthrequestdtoCall.callService();	
		 	 
			 Logger.verifyEquals(true, signauthrequestdtoCall.getSuccess(), "验证Success");
			 Logger.verifyEquals(200, signauthrequestdtoCall.getCode(), "验证Code");
			 Logger.verifyEquals(userTokenDtoBean.getUserId(), signauthrequestdtoCall.getUserId(), "验证userid");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_SignAuthRequestDto_016() {
		Logger.start(true,"有效的token,sellerpc返回成功,验证有效期");
		try {
			//创建用户
			 CreateUserReq cur = new CreateUserReq();
			 cur = JUserCallService.initCreateUserBean(cur);
			 int uid = JUserCallService.createUserCall(cur);
			 Thread.sleep(100);
			 //创建token
			 userTokenDtoBean.setUserId(uid);
			 userTokenDtoBean.setTokenSource("SellerPc");
			 userTokenDtoBean.setContext("reg");
			 userTokenDtoBean.setDeviceId("	");
			 userTokenDtoBean.setClientIp("132.36.75.32");
			 userTokenDtoCall.setData(userTokenDtoBean);
			 userTokenDtoCall.callService();
			 
			 String token = userTokenDtoCall.getResult();
			//修改token时间uTime
			 Map<String, Object> userlst= userTokenWapper.getUserUidByToken(token);
			 Date et1 = (Date) userlst.get("eTime");
				//now - uTime > 10 分钟，刷 eTime
				 String EndTime = YMTDateUtil.getBeforeOrNextDay(-1, YMTDateUtil.YMDHMSS);
				 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
				 Date endTime = sdf.parse(EndTime);
				userTokenWapper.updateUTimeByUserId(uid, endTime);
				
			signauthrequestdtoBean.setToken(token);
			signauthrequestdtoBean.setSClientType("testtype");
			signauthrequestdtoBean.setDeviceId("123457");
			signauthrequestdtoBean.setTokenSource("SellerPc");
			signauthrequestdtoBean.setClientIp("172.17.21.254");
			
			signauthrequestdtoCall.setData(signauthrequestdtoBean);
			signauthrequestdtoCall.callService();	
			
			Logger.verifyEquals(true, signauthrequestdtoCall.getSuccess(), "验证Success");
			Logger.verifyEquals(200, signauthrequestdtoCall.getCode(), "验证Code");
			
			if(userlst!=null && userlst.size()> 0)
			{
			  Logger.verifyEquals(userlst.get("uId"), signauthrequestdtoCall.getUserId(), "验证uid");
			}
			//检查etime是否变更
			userlst= userTokenWapper.getUserUidByToken(token);
			Date et2 = (Date) userlst.get("eTime");
			Logger.verifyNotEquals(et1, et2, "验证过期时间更新");
			//验证配置：sellerpc是24h
			Logger.debug(userlst);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}